//
//  CenterNewFriendTableCell.m
//  weibo
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CenterNewFriendTableCell.h"

@implementation CenterNewFriendTableCell

- (void)setMyModel:(NewFriendsModel *)myModel
{
    _myModel = myModel;
    self.userNameLabel.text = _myModel.userName;
    self.messageLabel.text  = _myModel.massege;
    [self.acceptButton addTarget:self action:@selector(acceptButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.refuseButton addTarget:self action:@selector(refuseButtonAction) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)acceptButtonAction
{
    EMError *error = nil;
    BOOL isSuccess = [[EaseMob sharedInstance].chatManager acceptBuddyRequest:self.myModel.userName error:&error];
    if (isSuccess && !error) {
        NSLog(@"发送同意成功");
        NSLog(@"isSucess ======2 %d",isSuccess);
        self.myBlock(isSuccess, self.myModel.userName);
        
    } else {
        NSLog(@"buchenggong");
    }

}

- (void)refuseButtonAction
{
    EMError *error = nil;
    BOOL isSuccess = [[EaseMob sharedInstance].chatManager rejectBuddyRequest:self.myModel.userName reason:@"111111" error:&error];
    if (isSuccess && !error) {
        NSLog(@"发送拒绝成功");
    }
 
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)dealloc {
    [_userNameLabel release];
    [_messageLabel release];
    [_acceptButton release];
    [_refuseButton release];
    [super dealloc];
}
@end
